package cn.emailChat.ai.filterchain;


/**
 * @Description 抽象处理器，封装公共的“串链与模板执行”逻辑
 * @Author susu
 * @Date 2025/8/20
 */
public abstract class AbstractFilterHandler implements FilterHandler {

    private FilterHandler next;

    @Override
    public FilterHandler setNext(FilterHandler next) {
        this.next = next;
        return next;
    }

    @Override
    public boolean filter(String email) {
        // 当前节点逻辑
        if (!doFilter(email)) {
            return false; // 当前节点拦截
        }
        // 交给下一个
        return next == null || next.filter(email);
    }

    /**
     * 子类实现：具体的过滤逻辑
     */
    protected abstract boolean doFilter(String email);
}
